package com.xy.iterator;

import java.util.Iterator;

/**
 * @author 谢阳
 * @version 1.8.0_131
 * @date 2022/6/17 20:33
 * @description
 */
public class ComputerCollegeIterator implements Iterator<Department> {
    // 数组存放
    private Department[] departments;
    int position = 0;

    public ComputerCollegeIterator(Department[] departments) {
        this.departments = departments;
    }

    @Override
    public boolean hasNext() {
        if (position >= departments.length || departments[position] == null) {
            return false;
        }
        return true;
    }

    @Override
    public Department next() {
        Department department = departments[position];
        position++;
        return department;
    }

    /**
     * 空实现
     */
    @Override
    public void remove() {
    }
}
